package com.deli;

public class DemoThread01 {
    public static void main(String[] args) throws InterruptedException {

        ThreadTest threadTest = new ThreadTest();
        threadTest.start();
        Thread.sleep(1000);
        threadTest.stopLt();
        Thread.sleep(2000);
        System.out.println("main方法");
        System.out.println(threadTest.getStop());
    }
}

class ThreadTest extends Thread {
    private boolean stop;

    public void run() {
        int i = 0;
        while (!stop) {
            i++;
        }
        System.out.println("test线程run方法中的i为:" + i);
    }

    public void stopLt() {
        stop = true;
    }

    public boolean getStop() {
        return stop;
    }
}
